package test;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;

/**
 * @author zhu
 * @date 2024-03-26
 */
public class MainTest03 {
    public static void main(String[] args) {
        Class<String> clazz = String.class;

        String strClassName = Modifier.toString(clazz.getModifiers());
        String className = clazz.getSimpleName();

        Method[] methods = clazz.getDeclaredMethods();

        System.out.println(strClassName + " class " + className + " {");
        for (Method method : methods) {
            String methodName = method.getName();
            String strMethodName = Modifier.toString(method.getModifiers());
            String typeName = method.getReturnType().getSimpleName();

            Parameter[] clz = method.getParameters();


            String paramTypeName = "";
            String paramName = "";
            String paramString = "";
            String strParam = "";
            for (Parameter param : clz) {
                paramTypeName = param.getType().getSimpleName();
                paramName = param.getName();

                String string = paramTypeName + " " + paramName + ",";
                paramString += string;
                strParam = paramString.substring(0,paramString.length()-1);
            }
            System.out.println("    " + strMethodName + " " + typeName + " " + methodName + "(" + strParam + ")");
        }

        System.out.println("}");
    }
}